package learning.directory.Work.排序.Tmt;

import java.util.Arrays;

/**
 * @author: tianmingtai
 * @create: 2021/02/19 10:52
 * @description:
 */

public class BubbleSortDay1 {
    public static void bubbleSort(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr.length - i - 1; j++) {
                if (arr[j] > arr[j + 1]) {
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
    }

    public static void main(String[] args) {
        int[] arr1 = {13, 9, 10, 92, 25, 38};
        // for (int i = 0; i < arr1.length; i++) {
        //     System.out.print(arr1[i] + " ");
        //
        // }


        // 打印数组新技能
        System.out.println("=============排序前============="+ Arrays.toString(arr1));
        bubbleSort(arr1);
        System.out.println("=============排序后============="+ Arrays.toString(arr1));
        // for (int i = 0; i < arr1.length; i++) {
        //     System.out.print(arr1[i] + " ");
        // }


    }

}
